<?php

namespace Home\Controller;

class Pk10Controller extends CommonController {
	

	function js_update() {
// 		$code_file=file_get_contents("http://www.bwlc.net/bulletin/prevtrax.html?num=614294");
// 		import("Org.Util.simple_html_dom");
// 		Vendor('phpQuery.phpQuery');
// 		header("Content-type: text/html; charset=utf-8");
		$code_key = $_REQUEST['code_key'];
// 		$code_key = S('code_key')+1;
		$html = new  \Org\Util\simple_html_dom();
		$html->load_file('http://www.bwlc.net/bulletin/prevtrax.html?num='.$code_key);
// 		$title = $html->find('title');
// 		$ret = $html->find('table tr td');
		$reault=array();
		foreach($html->find('div#lottery_tabs　.tb td') as $e){
			$ret = $e->innertext;
			array_push($reault, $ret);
		}
		$data['code_key']=$reault[0];
		$data['code']=$reault[1];
		$data['time']=$reault[2];
// 		dump($data);
		$model = D("Pk10");
		$where_find['code_key']=$reault[0];
		$result_find = $model->where($where_find)->find();
		if($result_find){
			$data['id']=$result_find['id'];
			$result_save = $model->save($data);
			S('code_key',$code_key);
			echo 1;
// 			dump("修改成功");
		}else{
			$result_add = $model->add($data);
			$data['id']=$result_add;
			echo 1;
// 			dump("添加成功");
		}
	}
	
	function pk10(){
		$this->display();
	}
	
}


